/*
===========================================================================
This source file is part of DyLab (Dynamic Laboratory)
For the latest info, see http://dylab-modules.googlecode.com

Copyright (c) 2006-2008 Lukas Krejci
(krejci.lukas@volny.cz)

This file is part of DyLab.

    DyLab is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    DyLab is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DyLab.  If not, see <http://www.gnu.org/licenses/>.
===========================================================================
*/

//===========================================================================================
#include "Ogre_Gfx.h"

//===========================================================================================
dylab::Ogre_Gfx::Entity::Entity(const String & _name, const String & _meshName, IScene * _scene)
{
    Ogre::SceneManager * ogreSceneMgr = dynamicCast<Scene>(_scene)->getOgreSceneMgr();

    mOgreEntity = ogreSceneMgr->createEntity(_name, _meshName);
    DYLAB_ASSERT(mOgreEntity != NULL);

    // attach object to scene node
    ogreSceneMgr->getRootSceneNode()->createChildSceneNode(_name)->attachObject(mOgreEntity);
}
//-----------------------------------------------------------------------------
dylab::Ogre_Gfx::Entity::~Entity()
{
}
//-----------------------------------------------------------------------------
dylab::String dylab::Ogre_Gfx::Entity::getName() const
{
    return mOgreEntity->getName();
}
//-----------------------------------------------------------------------------
void dylab::Ogre_Gfx::Entity::translate(const Vector3 & _v)
{
    mOgreEntity->getParentSceneNode()->translate(toOgreVector3(_v));
}
//-----------------------------------------------------------------------------
void dylab::Ogre_Gfx::Entity::rotate(const Vector3 & _axis, real_t _degrees)
{
    mOgreEntity->getParentSceneNode()->rotate(toOgreVector3(_axis), Ogre::Degree(_degrees));
}
//-----------------------------------------------------------------------------
void dylab::Ogre_Gfx::Entity::scale(const Vector3 & _scale)
{
    mOgreEntity->getParentSceneNode()->scale(toOgreVector3(_scale));
}
//-----------------------------------------------------------------------------
void dylab::Ogre_Gfx::Entity::setCastShadows(bool _castShadows)
{
    mOgreEntity->setCastShadows(_castShadows);
}
//-----------------------------------------------------------------------------
bool dylab::Ogre_Gfx::Entity::isCastingShadows() const
{
    return mOgreEntity->getCastShadows();
}
//-----------------------------------------------------------------------------
void dylab::Ogre_Gfx::Entity::setRayQueryFlags(uint32_t _flags)
{
    // set the ray scene query flags
    mOgreEntity->setQueryFlags(_flags);
}
//-----------------------------------------------------------------------------
dylab::uint32_t dylab::Ogre_Gfx::Entity::getRayQueryFlags() const
{
    return mOgreEntity->getQueryFlags();
}
//-----------------------------------------------------------------------------
void dylab::Ogre_Gfx::Entity::setMaterialName(const String & _material)
{
    mOgreEntity->setMaterialName(_material);
}
//-----------------------------------------------------------------------------